<template>
  <div>
    <myForm buttonTxt="登录" :userForm="{ loginname: '', password: '' }" url="/user/login" @submit="submit">
      <div>
        <router-link to="/register">没有账号去注册</router-link>
      </div>
    </myForm>
  </div>
</template>
<script>
import myForm from '../../components/form/form.vue'

export default {
  methods: {
    submit(res) {
      if (res.code === '200') {
        this.$router.push({ path: '/' })
        this.$store.commit('set_token', res.data.token)
        this.$store.commit('set_userid', res.data.userid)
      } else {
        alert(res.message)
      }
    }
  },
  components: {
    myForm
  }
}
</script>
